#include <iostream>
#include <cstring>
using namespace std;

int arr[2000001];
int main()
{
	int n;
	cin >> n;
	memset(arr, 0, 2000001);
	for(int i = 0; i < n; i++)
	{
		int temp;
		cin >> temp;
		arr[temp]++;
	}
	int max = arr[0];
	int maxI = 0;
	for(int i = 0; i < 2000001; i++)
	{
		if(max < arr[i])
		{
			max = arr[i];
			maxI = i;
		}
	}
	cout << maxI << endl;
	return 0; 
}
